
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%
    pageContext.setAttribute("path", request.getContextPath());
%>
<html>
<head>
    <title>Worker列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
    <link href="http://cdn.bootcss.com/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" />
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

    <script language="javascript">
        function del(id) {
            if (confirm("确认要删除？")) {
                window.location.href="${path}/worker/del/"+id;
            }
        }
    </script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1 align="center">
                    员工数据管理系统
                </h1>
            </div>
        </div>
    </div>


    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>查询结果</small>
                </h1>
            </div>
        </div>
    </div>


    <c:if test="${error != null}">

        ${error}

    </c:if>
    <c:if test="${error == null}">
        <div class="row clearfix">
            <div class="col-md-12 column">
                <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>籍贯</th>
                        <th>学历</th>
                        <th>地址</th>
                        <th>电话</th>
                        <th>工龄</th>
                        <th>基本工资</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>${worker.id}</td>
                        <td>${worker.name}</td>
                        <td>${worker.sex}</td>
                        <td>${worker.birthplace}</td>
                        <td>${worker.education}</td>
                        <td>${worker.address}</td>
                        <td>${worker.tele}</td>
                        <td>${worker.workage}</td>
                        <td>${worker.salary}</td>
                    </tr>
                    </tbody>
                </table>
                <h1>工资计算</h1>
                月有效工作天数：<input type="text" id="workday">
                月效益：<input type="text" id="workrate">
                月保险金：<input type="text" id="worksecure">
                <button id="btnGetSalary" style="height: 25px;width: 80px; margin-top: 10px" onclick="GetSalary(${worker.salary},${worker.workage})">计算工资</button>
                <div>
                    <span id="getSalary">

                    </span>
                </div>
                <script type="text/javascript">
                    function GetSalary(baseSalary,workage) {
                        var workday = parseInt(document.getElementById("workday").value);
                        var workrate = parseFloat(document.getElementById("workrate").value);
                        var worksecure = parseFloat(document.getElementById("worksecure").value);
                        var salary;

                        salary = (baseSalary + 10 * workday + workrate * workage / 100) * 0.9 - worksecure;
                        try{
                            document.getElementById("getSalary").innerText = "本月工资为：" + salary;
                        }
                        catch(e) {
                            alert("输入有误！！！");
                        }
                    }
                </script>
            </div>
        </div>

    </c:if>

</div>
